package net.wanho.zaixian.course.service.impl;

import net.wanho.zaixian.course.dao.CoursePicDao;
import net.wanho.zaixian.course.service.CoursePicService;
import net.wanho.zaixian.pojo.course.CoursePic;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

@Service
public class CoursePicServiceImpl implements CoursePicService {
    @Resource
    private CoursePicDao coursePicDao;
    @Override
    public void addCoursePic(CoursePic coursePic) {
        coursePicDao.save(coursePic);


    }

    @Override
    public List<CoursePic> getAllCoursePic() {
        List<CoursePic> coursePicList = coursePicDao.findAll();
        return coursePicList;
    }

    @Override
    public List<CoursePic> findCoursePicByCourseId(String courseId) {
        CoursePic coursePic = new CoursePic();
        coursePic.setCourseid(courseId);
        Example<CoursePic> example = Example.of(coursePic);
        List<CoursePic> coursePicList = coursePicDao.findAll(example);
        System.out.println(coursePicList);

        return coursePicList;
    }

    @Override
    public void deleteCoursePicByCourseId(String courseId) {
        coursePicDao.deleteById(courseId);

    }
}
